//
//  NeedSelectTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/17.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "NeedSelectTableViewCell.h"

@interface NeedSelectTableViewCell ()

@property (nonatomic, strong) UIImageView *selectImage;
@property (nonatomic, strong) UILabel *noteLabel;
@property (nonatomic, strong) UIButton *detailLabel;
@property (nonatomic, strong) UITextView *detailView;
@property (nonatomic, strong) UIImageView *bottomLine;

@end

@implementation NeedSelectTableViewCell

+ (NeedSelectTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"NeedSelectTableViewCell";
    NeedSelectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[NeedSelectTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.selectImage = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(16), ScreenX375(14), ScreenX375(14))];
    self.selectImage.image = [UIImage imageNamed:@"未选中"];
    [self addSubview:self.selectImage];
    
    self.noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(46), 0, ScreenX375(50), ScreenX375(47))];
    self.noteLabel.font = Kfont(16);
    [self addSubview:self.noteLabel];
    
    self.detailLabel = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(51), 0, ScreenX375(51), ScreenX375(47))];
    [self.detailLabel setTitle:@"说明" forState:UIControlStateNormal];
    [self.detailLabel setTitleColor:ThemeColor forState:UIControlStateNormal];
    self.detailLabel.titleLabel.font = Kfont(12);
    [self addSubview:self.detailLabel];
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(47) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    line.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:line];
    
    self.detailView = [[UITextView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(50), SCREEN_WIDTH - ScreenX375(26), ScreenX375(49))];
    self.detailView.font = Kfont(14);
    self.detailView.hidden = YES;
    [self addSubview:self.detailView];
    
    self.bottomLine = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(102) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    self.bottomLine.image = [UIImage imageNamed:@"虚线"];
    self.bottomLine.hidden = YES;
    [self addSubview:self.bottomLine];
}

- (void)setStatus:(BOOL)isSelect andTitle:(NSString *)title{
    self.noteLabel.text = title;
    if (isSelect) {
        self.detailView.hidden = NO;
        self.bottomLine.hidden = NO;
        self.selectImage.image = [UIImage imageNamed:@"选中"];
        self.noteLabel.textColor = ThemeColor;
    }else {
        self.detailView.hidden = YES;
        self.bottomLine.hidden = YES;
        self.selectImage.image = [UIImage imageNamed:@"未选中"];
        self.noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
